#ifndef BINARYFILEHELPER_H
#define BINARYFILEHELPER_H

#include <Windows.h>
#include <WindowsX.h>
#include <fstream>
#include "Utilities.h"

using namespace std;

class BinaryFileHelper
{
public:
	BinaryFileHelper(const char* fileName, ios_base::openmode openMode);
	~BinaryFileHelper();

	__CLR_OR_THIS_CALL operator void *() const;
	bool __CLR_OR_THIS_CALL operator!() const;

	void Write(const char* data, streamsize size);
	void Read(char* data, streamsize size);

	void WriteString(tstring str);
	tstring ReadString();

	void Flush();
	void Close();
	void Exceptions(ios_base::iostate newExceptions);
private:
	fstream* fileStream;
	bool closed;
};

#endif
